<#include "../inc/view.html"/>
<@view>
            <form id="sysRoleAddForm${nowtime}" name="sysRoleAddForm" class="form-horizontal" action="/admin/role/save" method="post" data-validator-option="{theme:'yellow_top'}">
                <input type="hidden" name="sysRole.id" value="${(po.id)!}">
            <div class="row">
                <div class="col-sm-6">
                    <ol class="breadcrumb">
                        <li>
                            <b>系统</b>
                        </li>
                        <li>
                            <a href="javascript:void(0);" onclick="contentLoadPage('/role')">角色</a>
                        </li>
                        <li class="active">
                            <#if po??>修改
                                <#else>新增
                            </#if>
                        </li>
                    </ol>
                </div>
                <div class="col-sm-6">
                    <a onclick="contentLoadPage('/role')" class="btn-sm btn-white pull-right" style="margin-left:10px;"><i class="ti-arrow-left"></i>返回</a>
                    <button type="submit" class="btn-sm btn-success pull-right"><i class="ti-save"></i>保存</button>
                </div>
            </div>
            <hr>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-md-2 control-label">角色名称</label>
                            <div class="col-md-10">
                                <input type="text" class="form-control" name="sysRole.name" data-rule="角色名称:required" value="${(po.name)!}">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-md-2 control-label">备注</label>
                            <div class="col-md-10">
                                <input type="text" class="form-control" name="sysRole.remark" value="${(po.remark)!}">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-md-2 control-label">状态</label>
                            <div class="col-md-10">
                                <label><input type="radio" name="sysRole.status" value="1" <#if 1==(po.status)!0 >checked</#if> /> 启用</label>
                                <label><input type="radio" name="sysRole.status" value="0" <#if 2==(po.status)!0 >checked</#if> />禁用</label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-12">
                        <div class="form-group">
                            <label class="col-md-2 control-label">设置权限</label>
                            <div class="col-md-10">
                                <table class="table table-bordered">
                                    <thead>
                                        <tr>
                                            <th>菜单</th>
                                            <th>按钮</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <#if menuList??>
                                        <#list menuList as m>
                                            <#if (''==(m.parentid)!'') && m.levelno==1>
                                                <tr>
                                                    <td><label><input type="checkbox" name="menuList" value="${m.id}"><i class="fa ${m.icon!}"></i>${m.name!}</label></td>
                                                    <td>&nbsp;</td>
                                                </tr>
                                                <#list menuList as mc>
                                                    <#if mc.levelno==2 && m.id==(mc.parentid)!>
                                                        <tr>
                                                            <td style="padding-left:50px;"><label><input type="checkbox" name="menuList" value="${mc.id}"><i class="fa ${mc.icon!}"></i>${mc.name!}</label></td>
                                                            <td>
                                                                <#list menuList as mt>
                                                                    <#if mc.id==(mt.parentid)! && mt.type==2 >
                                                                        <label style="margin-right:10px;"><input type="checkbox" name="menuList" value="${mt.id}"><i class="${mt.icon!}"></i>${mt.name}</label>
                                                                    </#if>
                                                                </#list>
                                                            </td>
                                                        </tr>
                                                    </#if>
                                                </#list>
                                            </#if>
                                        </#list>
                                    </#if>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
</@view>
<script>
    $(function(){
        ajaxForm($("#sysRoleAddForm${nowtime}"),function(json){
            if(json.code==RESULT_SUCCESS){
                contentLoadPage('/role');
            }else{
                if(json.msg)
                    layer.alert(json.msg,{icon:5,title:'系统提示',shadeClose:true});
            }
        });
        <#if roleMenuList??>
            <#list roleMenuList as m>
                $(":checkbox[name='menuList'][value='${m}']").attr('checked','checked');
            </#list>
        </#if>
    });
</script>